package com.ely.message.sms.listener;

import com.ely.coupon.common.core.constants.MessageConstants;
import com.ely.message.sms.dto.SmsInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.dromara.sms4j.api.SmsBlend;
import org.dromara.sms4j.api.entity.SmsResponse;
import org.dromara.sms4j.core.factory.SmsFactory;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RocketMQMessageListener(consumerGroup = MessageConstants.ConsumerGroup.MEMBER_COUPON_GROUP, topic = MessageConstants.Topic.TOPIC_MEMBER_CODE)
public class MemberPhoneCodeListener implements RocketMQListener<SmsInfo> {
    @Override
    public void onMessage(SmsInfo message){
        log.info(message.toString());
    SmsBlend smsBlend = SmsFactory.getSmsBlend("ali");
    SmsResponse smsResponse = smsBlend.sendMessage(message.getPhone(), message.getCode());

    }
}

